#define _CRT_SECURE_NO_WARNINGS 1
#pragma warning(disable:6031)

#include "Link.h"

static void Test1(void)
{
	ListNode* plist = ListInit();
	ListPushBack(plist, 1);
	ListPushBack(plist, 2);
	ListPushBack(plist, 3);
	ListPushBack(plist, 4);
	ListPrint(plist);
	ListPopBack(plist);
	ListPopBack(plist);
	ListPrint(plist);
	ListPopBack(plist);
	ListPopBack(plist);
	ListPopBack(plist);
	ListPrint(plist);
	Listdestroy(plist);
	plist = NULL;
}

static void Test2(void)
{
	ListNode* plist = ListInit();
	ListPushFront(plist, 10);
	ListPushFront(plist, 20);
	ListPushFront(plist, 30);
	ListPushFront(plist, 40);
	ListPrint(plist);
	ListPopFront(plist);
	ListPopFront(plist);
	ListPrint(plist);
	ListPopFront(plist);
	ListPopFront(plist);
	ListPopFront(plist);
	ListPrint(plist);
	Listdestroy(plist);
	plist = NULL;
}

static void Test3(void)
{
	ListNode* plist = ListInit();
	ListPushBack(plist, 1);
	ListPushBack(plist, 2);
	ListPushBack(plist, 3);
	ListPushBack(plist, 4);
	ListPushBack(plist, 5);
	ListPrint(plist);
	ListNode* pos = ListFind(plist, 3);
	ListInsert(pos, 114514);
	ListPrint(plist);
	Listdestroy(plist);
	plist = NULL;
}

static void Test4(void)
{
	ListNode* plist = ListInit();
	ListPushBack(plist, 1);
	ListPushBack(plist, 1);
	ListPushBack(plist, 2);
	ListPushBack(plist, 5);
	ListPushBack(plist, 7);
	ListPushBack(plist, 1);
	ListPushBack(plist, 9);
	ListPushBack(plist, 3);
	ListPushBack(plist, 1);
	ListPushBack(plist, 0);
	ListPrint(plist);
	ListNode* pos = ListFind(plist, 1);
	while (pos != NULL)
	{
		ListErase(pos);
		pos = ListFind(plist, 1);
		ListPrint(plist);
	}
	Listdestroy(plist);
	plist = NULL;
}

int main()
{
	//Test1();
	//Test2();
	//Test3();
	Test4();
	return 0;
}